package com.peng.commonlibrary.appupdate.usesystemdownload;

import android.app.Dialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.peng.commonlibrary.R;

/**
 * Created by M_genius on 2018/1/25 15:13.
 * 描述：app 更新提示的一般普通弹窗
 */

public class AppUpdateHintCommonDialog extends Dialog {

    Callback callback;
    private TextView content;
    private TextView sureBtn;
    private TextView cancelBtn;

    public AppUpdateHintCommonDialog(Context context, Callback callback) {
        super(context, R.style.AppUpdateHintDialog);
        this.callback = callback;
        initView();
    }

    private void initView() {
        View mView = LayoutInflater.from(getContext()).inflate(R.layout.dialog_app_update_common_hint, null);
        sureBtn = (TextView) mView.findViewById(R.id.dialog_confirm_sure);
        cancelBtn = (TextView) mView.findViewById(R.id.dialog_confirm_cancle);
        content = (TextView) mView.findViewById(R.id.dialog_confirm_title);


        sureBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                callback.callback(1);
                cancel();
            }
        });

        cancelBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                callback.callback(0);
                cancel();
            }
        });
        super.setContentView(mView);
    }

    /**
     * 设置对话框的提示内容
     * @param s
     * @return
     */
    public AppUpdateHintCommonDialog setContent(String s) {
        content.setText(s);
        return this;
    }
}
